﻿using AutoMapper;
using Fonour.Application.Dtos;
using Fonour.Application.Services.Interfaces;
using Fonour.Domain.Entities;
using Fonour.Domain.IRepositories;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Fonour.Application.Services
{
    public class RoleService : ServiceBase<RoleDto, Role>, IRoleService
    {
        private readonly IRoleRepository _roleRepository;
        private readonly IMapper _mapper;

        public RoleService(IRoleRepository roleRepository, IMapper mapper) : base(roleRepository, mapper)
        {
            this._roleRepository = roleRepository;
            this._mapper = mapper;
        }

        public async Task<List<Guid>> GetAllMenuListByRoleAsync(Guid roleId)
        {
            var menus = await this._roleRepository.GetAllMenuListByRoleAsync(roleId);
            return menus;
        }

        public bool UpdateRoleMenu(Guid roleId, List<RoleMenuDto> roleMenus)
        {
            return this._roleRepository.UpdateRoleMenu(roleId, this._mapper.Map<List<RoleMenu>>(roleMenus));
        }
    }
}
